package com.hejing.面向对象特征之二_继承.this关键字;

/**
 * ClassName: User
 * Package: com.hejing.this关键字
 * Description:
 *
 * @Author: HeJing
 * @Create: 2023-03-25 9:40
 * @Version: 1.0
 */
public class User {
    String name;
    int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    // 构造器
    public User() {

    }

    public User(String name) {
        this();  // 调用上面的空参构造器, 注意，不能写成 User(); why
        this.name = name;
    }

    public User(String name, int age) {
        this(name);  // 调用上面的单参构造器(name), 注意，不能写成User(name)
        // this.name = name;
        this.age = age;
    }
}

































